<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="product_sale" :rules="rules" label-width="100px" id="mvcfm">
          <div class="form-unit">
            <span class="mvc-title-left"> 增加记录 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="售后标题" prop="sale_title">
                  <el-input v-model="product_sale.sale_title" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="产品" prop="">
                  {{product_sale.product_id}}
                  <el-button @click="popProductSelection1('','product_id')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="维修状态" prop="sale_state">
                  <el-select style='width:100%' v-model="product_sale.sale_state">
                    <el-option label="待处理" value="0" />
                    <el-option label="已处理" value="1" />
                    <el-option label="已确认" value="2" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="问题说明" prop="sale_problem">
                  <el-input type="textarea" v-model="product_sale.sale_problem" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="remark">
                  <el-input type="textarea" v-model="product_sale.remark" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="increaseRecordSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/crm/sale/ServiceManage?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'售后管理'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="ProductSelection1Visible" append-to-body>
      <ProductSelection1 v-if="ProductSelection1Visible" ref="ProductSelection1" :popparams="popparams"> </ProductSelection1>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ProductSelection1 from "@/views/crm/supplychainmana/ProductSelection1";
  export default {
    name: 'IncreaseRecord',
    components: {
      ProductSelection1,
    },
    props: ['popparams'],
    data() {
      return {
        ProductSelection1Visible: false,
        ProductSelection1Value: null,
        ProductSelection1Desc: null,
        vueparams: this.getVUEParams(""),
        product_sale: {
          sale_title: null,
          product_id: null,
          sale_state: null,
          sale_problem: null,
          remark: null,
        },
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "售后管理"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      increaseRecordSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/crm/sale/AfterSaleAction/increaseRecordSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/crm/sale/SaleDetails/saleDetails?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popProductSelection1(desc, value) {
        this.ProductSelection1Visible = true;
        this.ProductSelection1Desc = desc;
        this.ProductSelection1Value = value;
      },
      closeProductSelection1(value, desc) {
        this.ProductSelection1Visible = false;
        this.$set(this.product_sale, this.ProductSelection1Desc, desc);
        this.$set(this.product_sale, this.ProductSelection1Value, value);
      },
    },
  }
</script>
